package com.example.service;

import com.example.entity.Sclass;
import com.example.entity.Score;
import com.example.mapper.SclassMapper;
import com.example.mapper.ScoreMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SclassService {

    @Resource
    private SclassMapper sclassMapper;

    public void add(Sclass sclass) {
        sclassMapper.insert(sclass);
    }

    public void deleteById(Integer id) {
        sclassMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Sclass sclass) {
        sclassMapper.updateById(sclass);
    }

    public Sclass selectById(Integer id) {
        return sclassMapper.selectById(id);
    }

    public List<Sclass> selectAll(Sclass sclass) {
        return sclassMapper.selectAll(sclass);
    }

    public PageInfo<Sclass> selectPage(Sclass sclass, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Sclass> scoreList = sclassMapper.selectAll(sclass);
        return PageInfo.of(scoreList);
    }
}
